#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/app-json/internal-functions"

trigger-app-json-pre-deploy() {
  declare desc="app-json scripts execution"
  declare trigger="pre-deploy"
  declare APP="$1" IMAGE_TAG="$2"
  local PHASE_SCRIPT_KEY="predeploy"

  execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY"
  execute_script "$APP" "$IMAGE_TAG" "release"
}

trigger-app-json-pre-deploy "$@"
